using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using net_work.Common.Result;
using net_work.IService.Cou;

namespace net_work.Controllers.Cou;

[Route("api/[controller]")]
[ApiController]
public class CurriculumController(ICurriculumService service, ILogger<CurriculumController> logger) : ControllerBase
{
    /// <summary>
    /// 获取课程表
    /// </summary>
    /// <param name="weekNum">周数</param>
    /// <returns>操作结果</returns>
    [HttpGet("get")]
    [Authorize]
    public async Task<IActionResult> GetCurriculum([FromQuery] int weekNum)
    {
        logger.LogInformation("获取课程表");

        var curriculumResults = await service.GetCurriculumAsync(weekNum);
        return curriculumResults != null ? AjaxResult.Success(curriculumResults) : AjaxResult.Error();
    }
}